home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performSubdivDisplaySmoothne1 < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.8 KB  |  366 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //  Alias|Wavefront Script File
  18. //  MODIFY THIS AT YOUR OWN RISK
  19. //
  20. //  Creation Date:  3 February, 1999
  21. //  Author:         nrohm
  22. //
  23. //  Procedure Name:
  24. //      performSubdivDisplaySmoothnessHull(string $operation, int $option)
  25. //
  26. //  Description:
  27. //        
  28. //
  29. //  Input Arguments:
  30. //        
  31. //
  32. //  Return Value:
  33. //      None.
  34. //
  35.  
  36. proc setOptionVars(int $forceFactorySettings)
  37. {
  38.     if ($forceFactorySettings || !`optionVar -exists subDivDispSmoothnessHullObjsAffected`) {
  39.         optionVar -intValue subDivDispSmoothnessHullObjsAffected 1;
  40.     }
  41. }
  42.  
  43. //
  44. //  Procedure Name:
  45. //      subdivDisplaySmoothnessHullSetup
  46. //
  47. //  Description:
  48. //        Update the state of the option box UI to reflect the option values.
  49. //
  50. //  Input Arguments:
  51. //      parent               - Top level parent layout of the option box UI.
  52. //                             Required so that UI object names can be 
  53. //                             successfully resolved.
  54. //
  55. //    forceFactorySettings - Whether the option values should be set to
  56. //                             default values.
  57. //
  58. //  Return Value:
  59. //      None.
  60. //
  61. global proc subdivDisplaySmoothnessHullSetup(string $parent, int $forceFactorySettings)
  62. {
  63.     //    Retrieve the option settings
  64.     //
  65.     setOptionVars($forceFactorySettings);
  66.  
  67.     setParent $parent;
  68.  
  69.     //    Objects Affected Radio Button 
  70.     //
  71.     int $subdivObjsAffected = `optionVar -q subDivDispSmoothnessHullObjsAffected`;
  72.     radioButtonGrp -e -sl $subdivObjsAffected subdivObjsAffectedRadio;    
  73. }
  74.  
  75. //
  76. //  Procedure Name:
  77. //      subdivDisplaySmoothnessHullCallback
  78. //
  79. //  Description:
  80. //        Update the option values with the current state of the option box UI.
  81. //
  82. //  Input Arguments:
  83. //      parent - Top level parent layout of the option box UI.  Required so
  84. //               that UI object names can be successfully resolved.
  85. //
  86. //    doIt   - Whether the command should execute.
  87. //
  88. //  Return Value:
  89. //      None.
  90. //
  91. global proc subdivDisplaySmoothnessHullCallback(string $parent, int $doIt)
  92. {
  93.     setParent $parent;
  94.  
  95.     //    Set the optionVar's from the control values, and then
  96.     //    perform the command.
  97.  
  98.     int $subdivObjsAffected = `radioButtonGrp -q -sl subdivObjsAffectedRadio`;
  99.     optionVar -intValue subDivDispSmoothnessHullObjsAffected $subdivObjsAffected;
  100.  
  101.     if ($doIt) {
  102.         performSubdivDisplaySmoothnessHull 0; 
  103.         addToRecentCommandQueue "performSubdivDisplaySmoothnessHull 0" "SubdivDisplaySmoothnessHull";
  104.     }
  105. }
  106.  
  107. //
  108. //  Procedure Name:
  109. //      subdivDisplaySmoothnessHullOptions
  110. //
  111. //  Description:
  112. //        Construct the option box UI.  Involves accessing the standard option
  113. //        box and customizing the UI accordingly.
  114. //
  115. //  Input Arguments:
  116. //      None.
  117. //
  118. //  Return Value:
  119. //      None.
  120. //
  121. proc subdivDisplaySmoothnessHullOptions()
  122. {
  123.     //    Name of the command for this option box.
  124.     //
  125.     string $commandName = "subdivDisplaySmoothnessHull";
  126.  
  127.     //    Build the option box actions.
  128.     //
  129.     string $callback = ($commandName + "Callback");
  130.     string $setup = ($commandName + "Setup");
  131.  
  132.     //    STEP 1:  Get the option box.
  133.     //    ============================
  134.     //
  135.     //    The value returned is the name of the layout to be used as
  136.     //    the parent for the option box UI.
  137.     //
  138.     string $layout = getOptionBox();
  139.     setParent $layout;
  140.     
  141.     //    STEP 2:  Pass the command name to the option box.
  142.     //    =================================================
  143.     //
  144.     //    Any default option box behaviour based on the command name is set 
  145.     //    up with this call.  For example, updating the 'Help' menu item with
  146.     //    the name of the command.
  147.     //
  148.     setOptionBoxCommandName($commandName);
  149.     
  150.     //    STEP 3:  Activate the default UI template.
  151.     //    ==========================================
  152.     //
  153.     //    Activate the default UI template so that the layout of this 
  154.     //    option box is consistent with the layout of the rest of the 
  155.     //    application.
  156.     //
  157.     setUITemplate -pushTemplate DefaultTemplate;
  158.  
  159.     //    STEP 4: Create option box contents.
  160.     //    ===================================
  161.     //    
  162.     //    This, of course, will vary from option box to option box.    
  163.     
  164.     //    Turn on the wait cursor.
  165.     //
  166.     waitCursor -state 1;
  167.  
  168.     //    RECOMMENDATION:  Place the UI in a 'scrollable' layout.  A 
  169.     //    scrollable layout ensures that if the option box window is ever
  170.     //    resized such that it's entire contents is not visible then the 
  171.     //    scroll bars provided by the scrollable layout will allow the user
  172.     //    to access the hidden UI.  Two layouts currently supporting 
  173.     //    scrollable behaviour are the 'scrollLayout' and the 'tabLayout'.
  174.     //
  175.     // scrollLayout;
  176.     //
  177.     //    or...
  178.     //
  179.  
  180.     tabLayout -tabsVisible 0 -scrollable 1;
  181.     
  182.     string $parent = `columnLayout -adjustableColumn 1`;
  183.     
  184.     //    RECOMMENDATION:  Use the 'Grp' commands where possible because
  185.     //    they obey the formatting specified in the default template.
  186.     //    This will result in a more consistent look throughout the
  187.     //    application.
  188.     //    
  189.     radioButtonGrp -numberOfRadioButtons 2
  190.         -label "Objects Affected" -l1 "Active" -l2 "All" subdivObjsAffectedRadio;
  191.       
  192.     //    Turn off the wait cursor.
  193.     //
  194.     waitCursor -state 0;
  195.     
  196.     //    Step 5: Deactivate the default UI template.
  197.     //    ===========================================
  198.     //
  199.     setUITemplate -popTemplate;
  200.  
  201.     //    Step 6: Customize the buttons.  
  202.     //    ==============================
  203.     //
  204.     //    Provide more descriptive labels for the buttons.  This is not 
  205.     //    necessary, but in some cases, for example, a button labelled 
  206.     //    'Create' may be more meaningful to the user than one labelled
  207.     //    'Apply'.
  208.     //
  209.     //    Disable those buttons that are not applicable to the option box.
  210.     //
  211.     //    Attach actions to those buttons that are applicable to the option
  212.     //    box.  Note that the 'Close' button has a default action attached 
  213.     //    to it that will hide the window.  If a a custom action is
  214.     //    attached to the 'Close' button then be sure to call the 'hide the
  215.     //    option box' procedure within the custom action so that the option
  216.     //    box is hidden properly.
  217.  
  218.     //    'Apply' button.
  219.     //
  220.     string $applyBtn = getOptionBoxApplyBtn();
  221.     button -edit
  222.         -command ($callback + " " + $parent + " " + 1)
  223.         $applyBtn;
  224.  
  225.     //    'Save' button.
  226.     //
  227.     string $saveBtn = getOptionBoxSaveBtn();
  228.     button -edit 
  229.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  230.         $saveBtn;
  231.  
  232.     //    'Reset' button.
  233.     //
  234.     string $resetBtn = getOptionBoxResetBtn();
  235.     button -edit 
  236.         -command ($setup + " " + $parent + " " + 1)
  237.         $resetBtn;
  238.  
  239.     //    Step 7: Set the option box title.
  240.     //    =================================
  241.     //
  242.     setOptionBoxTitle("Subdiv Display Smoothness (Hull) Options");
  243.  
  244.     //    Step 8: Customize the 'Help' menu item text.
  245.     //    ============================================
  246.     //
  247.     setOptionBoxHelpTag( "DisplaySubdivSmoothnessHull" );
  248.  
  249.     //    Step 9: Set the current values of the option box.
  250.     //    =================================================
  251.     //
  252.     eval (($setup + " " + $parent + " " + 0));    
  253.     
  254.     //    Step 10: Show the option box.
  255.     //    =============================
  256.     //
  257.     showOptionBox();
  258. }
  259.  
  260. //
  261. //  Procedure Name:
  262. //      subdivDisplaySmoothnessHullHelp
  263. //
  264. //  Description:
  265. //        Return a short description about this command.
  266. //
  267. //  Input Arguments:
  268. //      None.
  269. //
  270. //  Return Value:
  271. //      string.
  272. //
  273. proc string subdivDisplaySmoothnessHullHelp()
  274. {
  275.     return 
  276.     "  Command: subdivDisplaySmoothness - Set display smoothness for subdivision surfaces\n" +
  277.     "Selection: Subdivision Surfaces";
  278. }
  279.  
  280. //
  281. //  Procedure Name:
  282. //      assembleCmd
  283. //
  284. //  Description:
  285. //        Construct the command that will apply the option box values.
  286. //
  287. //  Input Arguments:
  288. //      None.
  289. //
  290. proc string assembleCmd()
  291. {
  292.     string $cmd;
  293.  
  294.     setOptionVars(false);
  295.     int $subdivObjsAffected = `optionVar -q subDivDispSmoothnessHullObjsAffected`;
  296.  
  297.     if ($subdivObjsAffected == 1){
  298.       //
  299.       // Change the smoothness of only the active subdiv objects
  300.       //
  301.       $cmd = "subdivDisplaySmoothness -s 0;";
  302.     }
  303.     else {
  304.       //
  305.       // Change the smoothness of all subdiv objects
  306.       //
  307.       $cmd = "subdivDisplaySmoothness -s 0 -all;";
  308.     }
  309.  
  310.     return $cmd;
  311. }
  312.  
  313. //
  314. //  Procedure Name:
  315. //      performsubdivDisplaySmoothnessHull
  316. //
  317. //  Description:
  318. //        Perform the performsubdivDisplaySmoothnessHull command using 
  319. //      the corresponding 
  320. //        option values.  This procedure will also show the option box
  321. //        window if necessary as well as construct the command string
  322. //        that will invoke the optionBoxExample1 command with the current
  323. //        option box values.
  324. //
  325. //  Input Arguments:
  326. //      0 - Execute the command.
  327. //      1 - Show the option box dialog.
  328. //      2 - Return the command.
  329. //
  330. global proc string performSubdivDisplaySmoothnessHull(int $action)
  331. {
  332.     string $cmd = "";
  333.  
  334.     switch ($action) {
  335.  
  336.         //    Execute the command.
  337.         //
  338.         case 0:
  339.             //    Get the command.
  340.             //
  341.             $cmd = `assembleCmd`;
  342.  
  343.             //    Execute the command with the option settings.
  344.             //
  345.             eval($cmd);
  346.  
  347.             break;
  348.  
  349.         //    Show the option box.
  350.         //
  351.         case 1:
  352.             subdivDisplaySmoothnessHullOptions;
  353.             break;
  354.  
  355.         //    Return the command string.
  356.         //
  357.         case 2:
  358.             //    Get the command.
  359.             //
  360.             $cmd = `assembleCmd`;
  361.             break;
  362.     }
  363.     return $cmd;
  364. }
  365.  
  366.